package com.leyou.order.web;

import com.leyou.order.service.OrderService;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("pay")
public class PayController {

    @Autowired
    private OrderService orderService;


    /**
     * RequestBody: 以前：只能把json转成对象，其实不是，也可以是xml转成对象：前提导入xml的依赖
     * @param data  接收参数，把xml转成对象，导入xml的依赖
     * @return  produces = "application/xml"  ： 把对象转成xml返回给微信
     */
    @PostMapping(value = "/notify", produces = "application/xml")
    public ResponseEntity<Map<String,String>> wxNotify(@RequestBody  Map<String, String> data){
        return ResponseEntity.ok(orderService.wxNotify(data));
    }


}
